﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _070.EFCore一对多
{
	public class CommentConfig : IEntityTypeConfiguration<Comment>
	{
		public void Configure(EntityTypeBuilder<Comment> builder)
		{
			builder.ToTable("T_Comments");
			builder.Property(c => c.Message).IsRequired().IsUnicode();
			// 一对多
			builder.HasOne<Article>(c => c.Article)
				.WithMany(a => a.Comments)
				.HasForeignKey(c=>c.ArticleId).IsRequired();
			
		}
	}
}
